package com.situ.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Controller;
import com.situ.service.BeCommentService;
import com.situ.entity.BeComment;
import java.util.*;
/**
 * BeComment的路由接口服务
 * 
 * @author 胡文
 *
 */
@Controller
public class BeCommentController {

	/** BeCommentService服务 */
	@Autowired
	private BeCommentService beCommentService;
	
	/**
	 * 查询所有BeComment数据的方法
	 * @param value
	 * @return
	 */

	@RequestMapping(value = "doemo", produces = {"application/json;charset=UTF-8"})
	public String find(BeComment value,
					   @RequestParam(defaultValue ="1",required = false) int startPage ,
					   @RequestParam(defaultValue = "5",required = false) int PageSize
			,Map map) {


		PageHelper.startPage(startPage, PageSize);
		List<BeComment> list= beCommentService.find(value);
		PageInfo pageInfo = new PageInfo<BeComment>(list,5);
		map.put("pageInfo", pageInfo);
		map.put("startPage", startPage);
		map.put("PageSize", PageSize);
		map.put("list",list);
		return "doemo.html";
	}
	
	/**
	 * 通过id查询BeComment数据的方法
	 * 
	 * @return
	 */
	@RequestMapping(value = "queryBeCommentById/{id}", produces = {"application/json;charset=UTF-8"})
	public String findOne(@PathVariable(name="id") Object id,Map map) {
        BeComment obj=  beCommentService.findOne(id);
        map.put("BeComment",obj);
        return "页面名称自己改";
	}
	
	/**
	 * 插入BeComment属性不为空的数据方法
	 * 
	 * @return
	 */
	@RequestMapping(value = "saveBeComment", produces = {"application/json;charset=UTF-8"})
	public String save(BeComment value) {
		  beCommentService.saveNotNull(value);
        return "redirect:/queryBeComment";
	}
	
	/**
	 * 更新BeComment属性不为空的数据方法
	 * 
	 * @return
	 */
	@RequestMapping(value = "updateBeComment", produces = {"application/json;charset=UTF-8"})
	public String update(BeComment value) {
		  beCommentService.updateNotNullById(value);
          return "redirect:/queryBeComment";
	}
	
	/**
	 * 通过id删除BeComment数据方法
	 * 
	 * @return
	 */
	@RequestMapping(value = "delBeCommentById/{id}", produces = {"application/json;charset=UTF-8"})
	public String delete(@PathVariable(name="id") Object id) {
		  beCommentService.deleteById(id);
          return "redirect:/queryBeComment";
	}
}
